<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="models.StaffModel"%>
<%@page import="helpers.PaginatorHelper"%>
<%@page import="helpers.UrlHelper"%>
<%@page import="java.util.ArrayList"%>
<%
ArrayList<StaffModel> users = (ArrayList<StaffModel>) request.getAttribute("users");
int pages = (Integer) request.getAttribute("page");
boolean nextPage = (Boolean) request.getAttribute("nextPage");
boolean prevPage = (Boolean) request.getAttribute("prevPage");
PaginatorHelper paginator = (PaginatorHelper) request.getAttribute("paginator");
%>

<jsp:include page="/admin/layouts/header.jsp">
    <jsp:param name="language" value="1" />
</jsp:include>

<script type="text/javascript" src="/admin/js/list_staff.js"></script>
<script type="text/javascript" src="/admin/js/list_form.js"></script>
<script type="text/javascript">
<!--
var server = "<%=UrlHelper.getServerUrl(request)%>";
//-->
</script>
        <div class="maincontent noright">
        	<div class="maincontentinner">
            	
                <ul class="maintabmenu">
                	<li class="current"><a href="/admin/staff/list">Quản lý nhân viên</a></li>
                	<li><a href="/admin/staff/add">Thêm nhân viên</a></li>
                </ul><!--maintabmenu-->
                
                <div class="content">
                	<div class="contenttitle radiusbottom0">
	                	<h2 class="table"><span>Danh sách nhân viên</span></h2>
	                </div>
	                
	                <div class="tableoptions">
	                    <select class="radius3 action-value">
	                    	<option value="status_active">Chuyển trạng thái kích hoạt</option>
	                        <option value="status_pending">Chuyển sang trạng thái đang xác nhận</option>
	                        <option value="status_inactive">Chuyển sang trạng thái chưa kích hoạt</option>
	                        <option value="delete">Xóa nhân viên đang được chọn</option>
	                    </select> &nbsp;
	                    <button class="radius3 apply-change">Thực hiện</button>
	                </div>
	                
	                <table cellspacing="0" cellpadding="0" border="0" class="stdtable stdtablecb" id="list-table">
	                    <colgroup>
	                        <col class="con0">
	                        <col class="con1">
	                        <col class="con0">
	                        <col class="con1">
	                        <col class="con0">
	                        <col class="con1">
	                    </colgroup>
	                    <thead>
	                        <tr>
	                        	<th class="head0"><span class="checkbox"><input type="checkbox" class="checkall"></span></th>
	                            <th class="head1">Tài khoản email</th>
	                            <th class="head0">Tên đầy đủ</th>
	                            <th class="head1">Trạng thái</th>
	                            <th class="head0">Quyền</th>
	                            <th class="head1">Thao tác</th>
	                        </tr>
	                    </thead>
	                    <tfoot>
	                        <tr>
	                        	<th class="head0"><span class="checkbox"><input type="checkbox" class="checkall"></span></th>
	                            <th class="head1">Tài khoản email</th>
	                            <th class="head0">Tên đầy đủ</th>
	                            <th class="head1">Trạng thái</th>
	                            <th class="head0">Quyền</th>
	                            <th class="head1">Thao tác</th>
	                        </tr>
	                    </tfoot>
	                    <tbody>
	                    	<% for (int i = 0; i < users.size(); i++) { %>
	                        <tr>
	                        	<td class="center"><span class="checkbox"><input type="checkbox" value="<%=users.get(i).getUsername()%>"></span></td>
	                            <td><%=users.get(i).getUsername() %></td>
	                            <td><%=users.get(i).getName() %></td>
	                            <td class="center">
	                            	<%
									switch (users.get(i).getStatus()) {
										case 0: 
											%>Chưa kích hoạt<%
											break;
										case 1:
											%>Đang xác nhận<%
											break;
										case 2:
											%>Kích hoạt<%
											break;
										default:
											break;
									}
									%>
	                            </td>
	                            <td class="center">
	                            	<%=users.get(i).getRole()== 1 ? "Sale" : "" %>
	                            	<%=users.get(i).getRole()== 2 ? "Bán hàng trực tiếp" : "" %>
	                            	<%=users.get(i).getRole()== 3 ? "Giao nhận" : "" %>
	                            	<%=users.get(i).getRole()== 4 ? "Kho" : "" %>
	                            	<%=users.get(i).getRole()== 5 ? "Điều phối, xuất tuyến" : "" %>
	                            	<%=users.get(i).getRole()== 6 ? "Kế toán" : "" %>
	                            	<%=users.get(i).getRole()== 7 ? "Marketing" : "" %>
	                            	<%=users.get(i).getRole()== 8 ? "CEO" : "" %>
	                            	<%=users.get(i).getRole()== 9 ? "Admin quản trị hệ thống" : "" %>
	                            </td>
	                            <td class="center">
									<a title="Edit Link" href="/admin/staff/edit/<%=users.get(i).getUsername()%>" class="edit">
										Sửa
									</a>&nbsp;
									<a title="Remove Link" href="/admin/staff/delete/<%=users.get(i).getUsername()%>" id="action_del" class="delete">
										Xóa
									</a>
								</td>
	                        </tr>
	                        <% } %>
	                    </tbody>
	                </table>
	                <!-- paginate -->
	                <div class="dataTables_paginate paging_full_numbers" id="dyntable_paginate">
	                	<% if (prevPage) { %>
							<a class="previous paginate_button" id="dyntable_previous" href="<%=paginator.getPrev()%>">Trang trước</a>
						<% } else { %>
							<span class="previous paginate_button paginate_button_disabled" id="dyntable_previous">Trang trước</span>
						<% } %>
						<% if (nextPage) { %>
							<a class="next paginate_button" id="dyntable_next"  href="<%=paginator.getNext()%>">Trang tiếp</a>
						<% } else { %>
							<span class="next paginate_button paginate_button_disabled" id="dyntable_next">Trang tiếp</span>
						<% } %>
	                </div>
                </div><!--content-->
                
            </div><!--maincontentinner-->
            
            <jsp:include page="/admin/elements/copyright.jsp">
            	<jsp:param name="language" value="1" />
			</jsp:include>
            
        </div><!--maincontent-->
        
<jsp:include page="/admin/layouts/footer.jsp">
    <jsp:param name="language" value="1" />
</jsp:include>